package cn.tedu.project.oa.attendanceRule.service.impl;

import cn.tedu.project.oa.attendanceRule.mapper.LeaveTypeMapper;
import cn.tedu.project.oa.attendanceRule.pojo.entity.LeaveType;
import cn.tedu.project.oa.attendanceRule.service.ILeaveTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class LeaveTypeServiceImpl implements ILeaveTypeService {
    @Autowired
    private LeaveTypeMapper leaveTypeMapper;

    /**
     * 查询请假类型
     *
     * @param id 请假类型主键
     * @return 请假类型
     */
    @Override
    public LeaveType selectLeaveTypeById(Long id)
    {
        return leaveTypeMapper.selectLeaveTypeById(id);
    }

    /**
     * 查询请假类型列表
     *
     * @param leaveType 请假类型
     * @return 请假类型
     */
    @Override
    public List<LeaveType> selectLeaveTypeList(LeaveType leaveType)
    {
        return leaveTypeMapper.selectLeaveTypeList(leaveType);
    }

    /**
     * 新增请假类型
     *
     * @param leaveType 请假类型
     * @return 结果
     */
    @Override
    public int insertLeaveType(LeaveType leaveType)
    {
        leaveType.setCreateTime(new Date());
        return leaveTypeMapper.insertLeaveType(leaveType);
    }

    /**
     * 修改请假类型
     *
     * @param leaveType 请假类型
     * @return 结果
     */
    @Override
    public int updateLeaveType(LeaveType leaveType)
    {
        leaveType.setUpdateTime(new Date());
        return leaveTypeMapper.updateLeaveType(leaveType);
    }

    /**
     * 批量删除请假类型
     *
     * @param ids 需要删除的请假类型主键
     * @return 结果
     */
    @Override
    public int deleteLeaveTypeByIds(Long[] ids)
    {
        return leaveTypeMapper.deleteLeaveTypeByIds(ids);
    }

    /**
     * 删除请假类型信息
     *
     * @param id 请假类型主键
     * @return 结果
     */
    @Override
    public int deleteLeaveTypeById(Long id)
    {
        return leaveTypeMapper.deleteLeaveTypeById(id);
    }
}
